From 79907b4b0845cd963a90a7a8f6340771a472ef70 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Tue, 17 Aug 2010 03:07:27 +0000 Subject: [PATCH] =?utf8?q?OverloardQ=20or=20other=20PG=20person,=20please?= =?utf8?q?=20review=20These=20patches=20were=20necessary=20to=20get=20new-?= =?utf8?q?installer=20working=20on=20PG=20for=20me.=20=20I'm=20not=20sure?= =?utf8?q?=20about=20the=20=E2=80=98create=20lang'=20bits=20=E2=80=94=20th?= =?utf8?q?ey=20should=20maybe=20be=20in=20another=20step=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- includes/installer/DatabaseInstaller.php | 6 ++-- includes/installer/PostgresInstaller.php | 39 +++++++++++++----------- maintenance/postgres/tables.sql | 1 + 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 7342fa2bae..67f2479b1e 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -302,11 +302,11 @@ abstract class DatabaseInstaller { if ( !$status->isOK() ) { return false; } - $conn = $status->value; - if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) { + + if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) { return false; } - return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' ); + return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' ); } /** diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index bb812e84ba..8b3643c76b 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -18,15 +18,8 @@ class PostgresInstaller extends DatabaseInstaller { 'wgDBts2schema', ); - protected $internalDefaults = array( - '_InstallUser' => 'postgres', - '_InstallPassword' => '', - ); - var $minimumVersion = '8.1'; - var $conn; - function getName() { return 'postgres'; } @@ -80,40 +73,39 @@ class PostgresInstaller extends DatabaseInstaller { // Try to connect if ( $status->isOK() ) { - $status->merge( $this->attemptConnection() ); + $status->merge( $this->getConnection() ); } if ( !$status->isOK() ) { return $status; } // Check version - $version = $this->conn->getServerVersion(); + $version = $this->db->getServerVersion(); if ( version_compare( $version, $this->minimumVersion ) < 0 ) { return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version ); } + + $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); + $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); return $status; } - function attemptConnection() { + function getConnection() { $status = Status::newGood(); try { - $this->conn = new DatabasePostgres( + $this->db = new DatabasePostgres( $this->getVar( 'wgDBserver' ), $this->getVar( '_InstallUser' ), $this->getVar( '_InstallPassword' ), - 'postgres' ); - $status->value = $this->conn; + $this->getVar( 'wgDBname' ) ); + $status->value = $this->db; } catch ( DBConnectionError $e ) { $status->fatal( 'config-connection-error', $e->getMessage() ); } return $status; } - function getConnection() { - return $this->attemptConnection(); - } - function getSettingsForm() { return false; } @@ -126,6 +118,19 @@ class PostgresInstaller extends DatabaseInstaller { } function createTables() { + $status = $this->getConnection(); + if ( !$status->isOK() ) { + return $status; + } + $this->db->selectDB( $this->getVar( 'wgDBname' ) ); + + global $IP; + $err = $this->db->sourceFile( "$IP/maintenance/postgres/tables.sql" ); + if ( $err !== true ) { + //@todo or...? + $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ ); + } + return Status::newGood(); } function getLocalSettings() { diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 60d0413f52..f45b5057d3 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -72,6 +72,7 @@ CREATE INDEX page_mediawiki_title ON page (page_title) WHERE page_namespace = CREATE INDEX page_random_idx ON page (page_random); CREATE INDEX page_len_idx ON page (page_len); +CREATE LANGUAGE 'plpgsql'; CREATE FUNCTION page_deleted() RETURNS TRIGGER LANGUAGE plpgsql AS $mw$ BEGIN -- 2.20.1